package com.ksana.aop.framework;

public class ProxyFactory {
    private AdvisedSupport advised;

    public ProxyFactory(AdvisedSupport advised) {
        this.advised = advised;
    }

    public Object getProxy() {
        return createAopProxy().getProxy();
    }

    private AopProxy createAopProxy() {
        if (advised.isProxyTargetClass()) {
            return new CglibAopProxy(advised);
        }

        return new JdkDynamicAopProxy(advised);
    }
}
